/**
 * @Author: admin
 * @Description:
 * @Date: 2018/10/16 17:38
 */

public class SellTicket implements Runnable {
    private int ticketCount = 1000;

    @Override
    public void run() {
        while (ticketCount > 0) {
            try {
                Thread.sleep(6);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            sale();

        }
    }

    private void sale() {
        System.out.println(Thread.currentThread().getName() + " 售出第： " + (1000 - (--ticketCount)) + " 张票");
    }

    public static void main(String[] args) {
        SellTicket sellTicket = new SellTicket();
        Thread t1 = new Thread(sellTicket, "窗口1");

        SellTicket sellTicket2 = new SellTicket();
        Thread t2 = new Thread(sellTicket, "窗口2");
        Thread t3 = new Thread(sellTicket, "窗口3");
        t1.start();
        t2.start();
        t3.start();
    }
}
